<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        未完成事项：{{ activeCount }}
        <button @click="push">新增</button>
    </div>
    <script type="module">
        import {createApp, reactive, computed} from "./node_modules/vue/dist/vue.esm-browser.js"
        const data = [
            {text: "看书", completed: false},
            {text: "敲代码", completed: false},
            {text: "睡觉", completed: true},
        ]

        createApp({
            setup() {
                const todos = reactive(data)
                const activeCount = computed(() => {
                    return todos.filter(item => !item.completed).length
                })
                return {
                    activeCount,
                    push: () => {
                        todos.push({text: "打游戏", completed: false})
                    }
                }
            }
        }).mount("#app")
    </script>
</body>
</html>